home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
BBS Toolkit
/
BBS Toolkit.iso
/
maximus
/
mul100.zip
/
PHONEFIX.SCR
< prev
next >
Wrap
Text File
|
1993-02-01
|
3KB
|
96 lines
// PHONEFIX.SCR -- Maximus User Base Phone Formatter -- Version 1.00
//
// Script program for MUL - the Maximus User Language
// MUL is (C) Copyright 1990-93 by CodeLand Australia
// PhoneFix formats the telephone field in all user file records, using
// a supplied pattern mask (the phonemask string below). Edit the
// phonemask string to match your local requirements.
char *ufile = "USER.BBS"; // Path & name of Maximus user file
//char *ufile = "C:\\BBS\\USER.BBS"; // Path & name of Maximus user file
char *phonemask = "(###) ###-####"; // Format string
char *banner = "PHONEFIX v1.00"; // Script banner
char *desc = "Maximus Phone Formatter"; // Description
// Optionally post a message to accounts without a phone entry
char *warnpho = "MsgPost -TC:\\Util\\WarnPho.Txt \"-F%s\"";
main () // Main program
{
int rec=2; // Starting record number
char buf[128]; // Work buffer
printf ("\n%s - %s\n\n",banner,desc); // Announce
if (!BaseOpen (ufile)) {
printf ("ERROR opening user file %s\n",ufile);
exit ();
}
// Process all records
while (BaseRead (rec)) {
if (!USRflagdel) { // Only non-deleted records
if (fix_phone (rec)) BaseWrite (rec);
// else { sprintf (buf,warnpho,USRname); system (buf); }
}
++rec;
}
BaseClose (); // Close the user base
saybibi (); // Was it good for you too?
}
fix_phone (int rec) // Adjust user phone field
{
char *p, *q, newphone[20], oldphone[20];
// Get the data
strcpy (newphone,phonemask); reverse (newphone);
strcpy (oldphone,USRphone); reverse (oldphone);
if (!oldphone[0]) { // Abort if no entry
printf("%04u %-25s NO PHONE ENTRY!\n",rec,USRname);
return 0;
}
p=oldphone; q=newphone; // Point at last characters
while (TRUE) {
while (*p && !isdigit (*p)) p++; // Skip non digits
if (!*p) break; // End of string
while (*q && *q!='#') q++; // Skip all except # characters
if (!*q) break; // End of format string
*q++=*p++; // Transfer the number
}
// Out of format string
if (!*q) while (*p) *q++=*p++; // Transfer the rest
// Out of numerics
else while (*q) {
if (*q=='#') *q=' '; // Blank the left over format chars
q++;
}
*q='\0'; // Terminate the output
newphone[14]='\0'; reverse (newphone);
printf("%04u %-25s %-14s => %s\n",rec,USRname,USRphone,newphone);
strcpy (USRphone,newphone);
return 1;
}
// Byebye
saybibi ()
{
puts ("\nPhoneFix done!\n");
}
// End of script